<?php
require_once ROOT_PATH . 'models/QQGroupModel.class.php';
class Index extends Action implements IAction {
	/**
	 * <h2>日志对象</h2>
	 *
	 * @var Logger
	 */
	private $_logger;
	
	/**
	 */
	public function __construct() {
		parent::__construct ();
		Logger::configure ( ROOT_PATH . 'config/log_config.xml' );
		$this->_logger = Logger::getLogger ( __CLASS__ );
	}
	
	/**
	 * 首页的控制器动作
	 */
	public function indexAction() {
		$sessMgr = SessionManager::getSingleton ();
		$auth = new Auth ();
		$fLogin = $auth->isAuthed ();
		if ($fLogin) {
			$this->_logger->debug ( 'User Login###' );
			$auth->updateAuthCode ();
			$auth->sendToken ();
		}
		$vr = new SmartyViewHelper ();
		$vr->setTemplateDir ( ROOT_PATH . 'templates/bootstrap' );
		
		$qqGroupModel = new QQGroupModel ();
		$latestQQGroups = $qqGroupModel->getLatest ();
		$vr->assign ( 'latestQQGroups', $latestQQGroups );
		$vr->assign ( 'pageTitle', '首页' );
		$vr->assign ( 'siteTitle', 'QQ群黄页' );
		$vr->render ( 'file:index/index.htm' );
	}
	/*
	 * (non-PHPdoc) @see IAction::addListener()
	 */
	public function addListener(ActionListener $listener) {
		// TODO Auto-generated method stub
	}
	
	/*
	 * (non-PHPdoc) @see IAction::removeListener()
	 */
	public function removeListener(ActionListener $listener) {
		// TODO Auto-generated method stub
	}
	
	/*
	 * (non-PHPdoc) @see IAction::removeAllListener()
	 */
	public function removeAllListener() {
		// TODO Auto-generated method stub
	}
}